<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class logs extends CI_Controller
{
	protected $_templates;
	
	function __construct() 
	{
		parent::__construct();
		$this->load->model('logs_model','logs');
		$this->permit_library->check_permit();
		$this->session->set_userdata(array('Url'=>uri_string()));          
	}
	
	function index(){
		$this->listlogs();
	}
	
	function listlogs()
	{
		$data['title'] = 'Lịch sử thao tác của: '.$this->logs->get_admin_by_id($this->uri->segment(3))->login_name;
		$config['base_url'] = base_url().'logs/listlogs/'.$this->uri->segment(3);  
		$config['total_rows']   =  $this->logs->get_num_log($this->uri->segment(3));
		$data['num'] = $config['total_rows'];
		$config['per_page']  =   30;
		$config['uri_segment'] = 4; 
		$this->pagination->initialize($config);   
		$data['list'] =   $this->logs->get_all_log($this->uri->segment(3),$config['per_page'],$this->uri->segment(4));
		$data['pagination']    = $this->pagination->create_links(); 
		$this->_templates['page'] = 'logs/list';
		$this->site->load($this->_templates['page'],$data);          
	}
	
	function del(){
		$AdminID = $this->uri->segment(3);
		$this->db->where('admin_id',$AdminID);
		if($this->db->delete('logs')){
		  $this->session->set_flashdata('message','Xóa thành công');
		}else{
		  $this->session->set_flashdata('message','Xóa không thành công');
		}
		redirect('logs/listlogs/'.$AdminID);
	}
  
}
?>
